package com.matt.repository.impl;

import com.matt.repository.base.BaseNativeSqlRepository;
import com.matt.repository.base.CourseNativeRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * *******************************
 * Created by lch.
 * form com.matt
 * on 2018/12/01
 * *******************************
 */
@Slf4j
@Service
public class CourseNativeRepositoryImpl extends BaseNativeSqlRepository implements CourseNativeRepository {


    @Override
    public Integer findByTypeAndDeletedAndAreaId(int type, boolean delete, String areaId) {
        String sqlQuery = String.format("select max(typeCode) from course where  type='%s' and deleted=0 and areaId='%s'",type,areaId);
        List list = sqlSingleList(sqlQuery);
        if (list.size() > 0)
            return list.get(0)==null ? 0:Integer.parseInt(list.get(0).toString());
        return 0;
    }
}
